unit SmallStruct.Configuration.TSSModelConfiguration;

interface

uses
  Classes,
  SmallStruct.Core,
  SmallStruct.Core.TSSObjectContainer,
  SmallStruct.Configuration.TSSConfiguration,
  SmallStruct.Configuration;

type
  TSSModelFieldConfiguration = class(TSSConfiguration, ISSModelFieldConfiguration)
  private
    _FieldCaption, _FieldName: string;
    _IsPrimaryKey, _IsReadOnly, _IsRequired: Boolean;
  public
    function GetFieldCaption: string;
    function GetFieldName: string;
    function IsPrimaryKey: Boolean;
    function IsReadOnly: Boolean;
    function IsRequired: Boolean;
  public
    procedure SetFieldCaption(const AFieldCaption: string);
    procedure SetFieldName(const AFieldName: string);
    procedure SetPrimaryKey(const AIsPrimaryKey: Boolean);
    procedure SetReadOnly(const AIsReadOnly: Boolean);
    procedure SetRequired(const AIsRequired: Boolean);
  end;

  TSSModelConfiguration = class(TSSConfiguration, ISSModelConfiguration)
  private
    _ModelName, _DatabaseConnectionName, _EntityName, _OpenCondition: string;
    _IsAutoOpen, _IsReadOnly: Boolean;
    _FieldConfiguration: TSSObjectContainer;
    _Type: TSSModelType;
    _CataLog: Integer;
  public
    function GetModelName: string;
    function GetDatabaseConnectionName: string;
    function GetEntityName: string;
    function GetFieldConfiguration: ISSObjectContainer;
    function GetOpenCondition: string;
    function GetType: TSSModelType;
    function IsAutoOpen: Boolean;
    function IsReadOnly: Boolean;
  public
    procedure SetModelName(const AModelName: string);
    procedure SetDatabaseConnectionName(const ADatabaseConnectionName: string);
    procedure SetEntityName(const AEntityName: string);
    procedure SetOpenCondition(const AOpenCondition: string);
    procedure SetAutoOpen(const AIsAutoOpen: Boolean);
    procedure SetReadOnly(const AIsReadOnly: Boolean);
    procedure SetType(const AType: TSSModelType);
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;

implementation

{ TSSModelFieldConfiguration }

procedure TSSModelFieldConfiguration.SetFieldCaption(const AFieldCaption: string);
begin
  _FieldCaption := AFieldCaption;
end;

function TSSModelFieldConfiguration.IsPrimaryKey: Boolean;
begin
  Result := _IsPrimaryKey;
end;

function TSSModelFieldConfiguration.GetFieldName: string;
begin
  Result := _FieldName;
end;

procedure TSSModelFieldConfiguration.SetPrimaryKey(const AIsPrimaryKey: Boolean);
begin
  _IsPrimaryKey := AIsPrimaryKey;
end;

procedure TSSModelFieldConfiguration.SetFieldName(const AFieldName: string);
begin
  _FieldName := AFieldName;
end;

function TSSModelFieldConfiguration.IsReadOnly: Boolean;
begin
  Result := _IsReadOnly;
end;

function TSSModelFieldConfiguration.IsRequired: Boolean;
begin
  Result := _IsRequired;
end;

function TSSModelFieldConfiguration.GetFieldCaption: string;
begin
  Result := _FieldCaption;
end;

procedure TSSModelFieldConfiguration.SetReadOnly(const AIsReadOnly: Boolean);
begin
  _IsReadOnly := AIsReadOnly;
end;

procedure TSSModelFieldConfiguration.SetRequired(const AIsRequired: Boolean);
begin
  _IsRequired := AIsRequired;
end;

{ TSSModelConfiguration }

function TSSModelConfiguration.GetOpenCondition: string;
begin
  Result := _OpenCondition;
end;

function TSSModelConfiguration.GetType: TSSModelType;
begin
  Result := _Type;
end;

function TSSModelConfiguration.IsAutoOpen: Boolean;
begin
  Result := _IsAutoOpen;
end;

function TSSModelConfiguration.GetFieldConfiguration: ISSObjectContainer;
begin
  Result := _FieldConfiguration;
end;

function TSSModelConfiguration.GetModelName: string;
begin
  Result := _ModelName;
end;

function TSSModelConfiguration.IsReadOnly: Boolean;
begin
  Result := _IsReadOnly;
end;

function TSSModelConfiguration.GetEntityName: string;
begin
  Result := _EntityName;
end;

function TSSModelConfiguration.GetDatabaseConnectionName: string;
begin
  Result := _DatabaseConnectionName;
end;

procedure TSSModelConfiguration.SetEntityName(const AEntityName: string);
begin
  _EntityName := AEntityName;
end;

procedure TSSModelConfiguration.SetModelName(const AModelName: string);
begin
  _ModelName := AModelName;
end;

procedure TSSModelConfiguration.SetDatabaseConnectionName(const ADatabaseConnectionName: string);
begin
  _DatabaseConnectionName := ADatabaseConnectionName;
end;

procedure TSSModelConfiguration.SetOpenCondition(const AOpenCondition: string);
begin
  _OpenCondition := AOpenCondition;
end;

procedure TSSModelConfiguration.SetAutoOpen(const AIsAutoOpen: Boolean);
begin
  _IsAutoOpen := AIsAutoOpen;
end;

procedure TSSModelConfiguration.SetReadOnly(const AIsReadOnly: Boolean);
begin
  _IsReadOnly := AIsReadOnly;
end;

procedure TSSModelConfiguration.SetType(const AType: TSSModelType);
begin
  _Type := AType;
end;

constructor TSSModelConfiguration.Create(AOwner: TComponent);
begin
  inherited;
  _FieldConfiguration := TSSObjectContainer.Create(Self);
end;

destructor TSSModelConfiguration.Destroy;
begin
  _FieldConfiguration.ReleaseObject;
  _FieldConfiguration.Free;
  inherited;
end;

end.
